package cn.itcast.page;

import cn.itcast.bean.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Test01 {
    @Test
    public void showPage() throws IOException {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
//        PageHelper.startPage(1, 3);
        PageHelper.startPage(2,3);
        List<User> list = sqlSession.selectList("User.selectAll");
        for (User user1 : list) {
            System.out.println(user1);
        }
        is.close();
        sqlSession.close();
    }
}
